﻿using Axis.Web.Administrator.Global;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Axis.Web.Views.Captcha
{
    public partial class ucCaptcha : System.Web.UI.UserControl
    {
        // Inside the UserControl
        public bool IsValid
        {
            get
            {
                if (Session["CAPTCHA_CODE"] != null)
                {
                    string inputData = txtCaptchaCode.Text.Trim();
                    string captcha="";
                    
                      captcha=  Session["CAPTCHA_CODE"].ToString();
                    bool value = CSecurity.ValidateMD5HashData(inputData, captcha);
                    Session["CAPTCHA_CODE"] = null;
                    return value;
                }
                else
                {
                    return false;
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                imgCaptcha.ImageUrl = "~/Views/Captcha/ImageCaptcha.ashx?rand=" + DateTime.Now.Ticks.ToString();
            }
        }
    }
}